import request from '@/config/axios'

export interface EvalCandidateMaterialVO {
  id?: number
  candidateInfoId: number
  materialType: number
  materialName: string
  materialPath: string
  materialSize: number
  materialFormat: string
  uploadTime: string
  materialStatus: number
  auditComments?: string
  createTime?: Date
}

export interface EvalCandidateEducationVO {
  id?: number
  candidateInfoId: number
  educationLevel: number
  schoolName: string
  majorName: string
  graduationDate: string
  degreeType?: string
  certificateNumber?: string
  educationStatus: number
  createTime?: Date
}

export interface EvalCandidateWorkExperienceVO {
  id?: number
  candidateInfoId: number
  companyName: string
  positionName: string
  workStartDate: string
  workEndDate?: string
  workDescription?: string
  isCurrent: boolean
  experienceStatus: number
  createTime?: Date
}

export interface EvalCandidateCertificateVO {
  id?: number
  candidateInfoId: number
  certificateType: number
  certificateName: string
  certificateNumber: string
  issueOrganization: string
  issueDate: string
  expiryDate?: string
  certificateLevel?: string
  certificateStatus: number
  createTime?: Date
}

export interface EvalCandidateAchievementVO {
  id?: number
  candidateInfoId: number
  achievementType: number
  achievementName: string
  achievementDescription: string
  achievementDate: string
  achievementLevel?: string
  awardOrganization?: string
  achievementStatus: number
  createTime?: Date
}

// 材料管理相关API
export const getCandidateMaterialPage = (params: any) => {
  return request.get({ url: '/eval/candidate-material/page', params })
}

export const getCandidateMaterial = (id: number) => {
  return request.get({ url: '/eval/candidate-material/get?id=' + id })
}

export const createCandidateMaterial = (data: EvalCandidateMaterialVO) => {
  return request.post({ url: '/eval/candidate-material/create', data })
}

export const updateCandidateMaterial = (data: EvalCandidateMaterialVO) => {
  return request.put({ url: '/eval/candidate-material/update', data })
}

export const deleteCandidateMaterial = (id: number) => {
  return request.delete({ url: '/eval/candidate-material/delete?id=' + id })
}

export const getCandidateMaterialListByCandidateId = (candidateInfoId: number) => {
  return request.get({ url: '/eval/candidate-material/list-by-candidate?candidateInfoId=' + candidateInfoId })
}

export const uploadCandidateMaterial = (candidateInfoId: number, materialType: number, file: File) => {
  const formData = new FormData()
  formData.append('candidateInfoId', candidateInfoId.toString())
  formData.append('materialType', materialType.toString())
  formData.append('file', file)
  return request.post({ url: '/eval/candidate-material/upload', data: formData })
}

export const downloadCandidateMaterial = (id: number) => {
  return request.download({ url: '/eval/candidate-material/download?id=' + id })
}

export const auditCandidateMaterial = (id: number, materialStatus: number, auditComments?: string) => {
  return request.put({ url: '/eval/candidate-material/audit', data: { id, materialStatus, auditComments } })
}

// 学历信息相关API
export const getCandidateEducationPage = (params: any) => {
  return request.get({ url: '/eval/candidate-education/page', params })
}

export const getCandidateEducation = (id: number) => {
  return request.get({ url: '/eval/candidate-education/get?id=' + id })
}

export const createCandidateEducation = (data: EvalCandidateEducationVO) => {
  return request.post({ url: '/eval/candidate-education/create', data })
}

export const updateCandidateEducation = (data: EvalCandidateEducationVO) => {
  return request.put({ url: '/eval/candidate-education/update', data })
}

export const deleteCandidateEducation = (id: number) => {
  return request.delete({ url: '/eval/candidate-education/delete?id=' + id })
}

export const getCandidateEducationListByCandidateId = (candidateInfoId: number) => {
  return request.get({ url: '/eval/candidate-education/list-by-candidate?candidateInfoId=' + candidateInfoId })
}

// 工作经历相关API
export const getCandidateWorkExperiencePage = (params: any) => {
  return request.get({ url: '/eval/candidate-work-experience/page', params })
}

export const getCandidateWorkExperience = (id: number) => {
  return request.get({ url: '/eval/candidate-work-experience/get?id=' + id })
}

export const createCandidateWorkExperience = (data: EvalCandidateWorkExperienceVO) => {
  return request.post({ url: '/eval/candidate-work-experience/create', data })
}

export const updateCandidateWorkExperience = (data: EvalCandidateWorkExperienceVO) => {
  return request.put({ url: '/eval/candidate-work-experience/update', data })
}

export const deleteCandidateWorkExperience = (id: number) => {
  return request.delete({ url: '/eval/candidate-work-experience/delete?id=' + id })
}

export const getCandidateWorkExperienceListByCandidateId = (candidateInfoId: number) => {
  return request.get({ url: '/eval/candidate-work-experience/list-by-candidate?candidateInfoId=' + candidateInfoId })
}

// 证书信息相关API
export const getCandidateCertificatePage = (params: any) => {
  return request.get({ url: '/eval/candidate-certificate/page', params })
}

export const getCandidateCertificate = (id: number) => {
  return request.get({ url: '/eval/candidate-certificate/get?id=' + id })
}

export const createCandidateCertificate = (data: EvalCandidateCertificateVO) => {
  return request.post({ url: '/eval/candidate-certificate/create', data })
}

export const updateCandidateCertificate = (data: EvalCandidateCertificateVO) => {
  return request.put({ url: '/eval/candidate-certificate/update', data })
}

export const deleteCandidateCertificate = (id: number) => {
  return request.delete({ url: '/eval/candidate-certificate/delete?id=' + id })
}

export const getCandidateCertificateListByCandidateId = (candidateInfoId: number) => {
  return request.get({ url: '/eval/candidate-certificate/list-by-candidate?candidateInfoId=' + candidateInfoId })
}

// 工作业绩相关API
export const getCandidateAchievementPage = (params: any) => {
  return request.get({ url: '/eval/candidate-achievement/page', params })
}

export const getCandidateAchievement = (id: number) => {
  return request.get({ url: '/eval/candidate-achievement/get?id=' + id })
}

export const createCandidateAchievement = (data: EvalCandidateAchievementVO) => {
  return request.post({ url: '/eval/candidate-achievement/create', data })
}

export const updateCandidateAchievement = (data: EvalCandidateAchievementVO) => {
  return request.put({ url: '/eval/candidate-achievement/update', data })
}

export const deleteCandidateAchievement = (id: number) => {
  return request.delete({ url: '/eval/candidate-achievement/delete?id=' + id })
}

export const getCandidateAchievementListByCandidateId = (candidateInfoId: number) => {
  return request.get({ url: '/eval/candidate-achievement/list-by-candidate?candidateInfoId=' + candidateInfoId })
}
